﻿using Leo.Awesome.AppPlatform.Repostories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.MongoDB;
using Volo.Abp.PermissionManagement.MongoDB;

namespace Leo.Awesome.AppPlatform.Repostiries
{
    public class PermissionGrantAppRepository : MongoPermissionGrantRepository, IPermissionGrantAppRepository
    {
     

        public PermissionGrantAppRepository(IMongoDbContextProvider<IPermissionManagementMongoDbContext> dbContextProvider) 
            : base(dbContextProvider)
        {
            
        }

        public async Task DeleteByNameAsync(List<string> names, Guid? tenantId)
        {
            if (names.IsNullOrEmpty()) return;
            var query = await GetMongoQueryableAsync();
            var entites = query.Where(x => names.Contains(x.Name) && x.TenantId == tenantId);
            await base.DeleteManyAsync(entites);
        }
    }
}
